# -*- coding:utf-8 -*-
'''
@Author: lindes
'''

from django import forms
from users.models import UserProfile, Feedback


class UserRegForm(forms.ModelForm):
    email = forms.EmailField(label="邮箱", required=True)
    password = forms.CharField(min_length=6, max_length=20, label="密码", required=True)

    class Meta:
        model = UserProfile
        fields = ('email', 'password')

        error_messages = {
            'email': {
                "required": "邮箱必填"
            },
            'password': {
                'min_length': "密码长度不能小于6",
                'max_length': "密码长度不能大于20",
                "required": "密码必填"
            }
        }


class FeedbackForm(forms.ModelForm):
    title = forms.CharField(label="标题", max_length=20, required=True)
    content = forms.CharField(label="反馈内容", required=True)

    class Meta:
        model = Feedback
        fields = ('title', 'content')

        error_messages = {
            'title': {
                'max_length': '标题长度不能超过20',
                'required': '标题必填'
            },
            'content': {
                'required': '内容必填'
            }
        }
